<template>
   <div class="table_pane">
        <div class="table_body">
            <div class="icon_group">
                <!-- <div class="icon_item">
                     <el-icon><Plus /></el-icon>
                </div> -->
                <div class="icon_item">
                    <el-icon><RefreshRight @click="RefreshClick" /></el-icon>
                </div>
            </div>
            <el-table :data="tableData" size="small" style="width: 100%">
                <el-table-column show-overflow-tooltip fixed prop="fromUid" label="用户id" width="150" />
                <el-table-column show-overflow-tooltip prop="msgContent" label="消息内容" width="300" />
                <el-table-column show-overflow-tooltip prop="createTime" label="发送时间" width="150" />
                <el-table-column fixed="right" label="操作" min-width="120">
                <template #default>
                    <el-button link type="primary" size="small" @click="handleClick">
                    消息详情
                    </el-button>
                </template>
                </el-table-column>
            </el-table>
            <div class="page_pane">
                <el-pagination
                    :page-size="tableSize"
                    layout="total, prev, pager, next"
                    :total="tableTotal"
                    @prev-click="prevClick"
                    @next-click="nextClick"
                    @current-change="currentChange"
                />
            </div>
        </div>
    </div>
</template>
<script setup>
import { defineComponent,reactive, ref, unref, h, onMounted, nextTick, computed, getCurrentInstance} from 'vue'
import { messageApi } from '@/api/apis/message';
//表数据
const pageNum=ref(0);
const pageSize=ref(10);
const tableData = ref([])
const tableTotal=ref(0);
const tableSize=ref(10);
const toUid=ref('');
const currentChange=(num)=>{
    pageNum.value=num;
    pageData(num);;
}
//上一页
const prevClick=(num)=>{
    pageNum.value=num;
    pageData(num);
}
//下一页
const nextClick=(num)=>{
    pageNum.value=num;
    pageData(num);
}
const RefreshClick=()=>{
    pageData(pageNum.value);
}
const pageData=(pageNum)=>{
       messageApi.getMessageRecordPageToUid({pageNum:pageNum,pageSize:pageSize.value,toUid:toUid.value}).then((res)=>{
            tableData.value=res.records;
            tableTotal.value=res.total;
       })
}
//设置toUid
const setToUid=(uid)=>{
    toUid.value=uid;
    pageData(1);
}
// 暴露方法给父组件
defineExpose({
    setToUid
})
</script>
<style lang="css">

</style>